package xyz.zhno.factory.builder;

/**
 * User 实体
 * @author zh_o
 * @date 2020-11-14
 */
public class User {

    private String name;

    private Integer age;

    private String gender;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public static Builder builder() {
        return new Builder();
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                '}';
    }

    static class Builder {

        private User user = new User();

        public Builder name(String name) {
            user.setName(name);
            return this;
        }

        public Builder age(Integer age) {
            user.setAge(age);
            return this;
        }

        public Builder gender(String gender) {
            user.setGender(gender);
            return this;
        }

        public User build() {
            return user;
        }
    }

}
